package io.yunho.yunho.interview.one.singleton.createbyuse;

/**
 * @author: Jason
 * @date: 2021/3/8 10:15
 * @description:
 * 懒汉式
 */
public class SingletonUOneSafe {
    private static volatile SingletonUOneSafe INSTANCE;//使用volatile修饰 可以保证多个线程同时可见
    private SingletonUOneSafe(){}
    public static SingletonUOneSafe getInstance(){
        if (INSTANCE == null){
            synchronized (SingletonUOneSafe.class){
               if(INSTANCE == null){
                   INSTANCE = new SingletonUOneSafe();
               }
            }
        }
        return INSTANCE;
    }
}
